<template>
  <div id="app">

    <el-form ref="registerForm" :model="registerForm" :rules="registerRules" class="register-form" label-width="80px">
      <h3 class="title">核酸用户完成</h3>
      <el-form-item label="任务名" prop="tasks">
        <el-input v-model="registerForm.tasks" placeholder="请输入用户姓名" />
      </el-form-item>
      <el-form-item label="住户姓名" prop="householdName">
        <el-input v-model="registerForm.householdName" placeholder="请输入用户姓名" />
      </el-form-item>
      <el-form-item label="住户电话" prop="householdPhone">
        <el-input v-model="registerForm.householdPhone" placeholder="请输入手机号码"/>
      </el-form-item>



      <el-form-item style="width:100%;">
        <el-button
          :loading="loading"
          size="medium"
          type="primary"
          style="width:100%;"
          @click.native.prevent="getFinish"
        >
          <span v-if="!loading">完 成 核 酸</span>
          <span v-else>提 交 中...</span>
        </el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import {addHousehold, getUrl, updateFinish, updateHousehold} from "@/api/tasks/household";
import {getSendSmsCode} from "@/api/system/nucleicAcidUser";
import {listQuarters} from "@/api/basic/quarters";
import {listBuilding} from "@/api/basic/building";
import {getTaskUrl} from "@/api/tasks/task";

export default {
  name: "Register",
  data() {
    return {

      disabled: false,

      open: true,

      value: '',

      codeUrl: "",

      registerForm: {
        tasks: null,
        householdName: null,
        householdPhone: null,
      },
      // 查询参数
      queryParams: {
        tasks: null,
        householdName: null,
        householdPhone: null,
        url: null,
      },

      registerRules: {

      },
      loading: false,
      captchaEnabled: true
    };
  },
  methods: {
    getTask(){
      this.loading = true;
      const strUrl = document.location.toString();
      const arrObj = strUrl.split("//");
      const start = arrObj[1].indexOf("?");
      this.queryParams.url = arrObj[1].substring(start);
      getUrl(this.queryParams).then(response => {
        this.registerForm = response.data;
        this.loading = false;
      });
    },

    getFinish(){
      updateFinish(this.registerForm).then(res =>{
        if(res){
          this.$modal.msgSuccess("操作成功");
        }
      });
    }

  },

  mounted() {
    this.getTask();
  }
};
</script>

<style rel="stylesheet/scss" lang="scss">
.register {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
  background-image: url("../assets/images/login-background.jpg");
  background-size: cover;
}
.title {
  margin: 0px auto 40px auto;
  text-align: center;
  color: #707070;
}

.register-form {
  border-radius: 50px;
  background: #ffffff;
  width: 500px;
  padding: 25px 25px 5px 25px;
  .el-input {
    height: 38px;
    input {
      height: 38px;
    }
  }
  .input-icon {
    height: 39px;
    width: 14px;
    margin-left: 2px;
  }
}
.register-tip {
  font-size: 13px;
  text-align: center;
  color: #bfbfbf;
}
.register-code {
  width: 33%;
  height: 38px;
  float: right;
  img {
    cursor: pointer;
    vertical-align: middle;
  }
}
.el-register-footer {
  height: 40px;
  line-height: 40px;
  position: fixed;
  bottom: 0;
  width: 100%;
  text-align: center;
  color: #fff;
  font-family: Arial;
  font-size: 12px;
  letter-spacing: 1px;
}
.register-code-img {
  height: 38px;
}
</style>
